package adv_pre;

import java.util.HashSet;
import java.util.Set;

public class SetTest4 {

	public static void main(String[] args) {
		Set set = new HashSet();

		set.add(new News(1, "双十一花了一毛", "老刘", null));
		set.add(new News(2, "双十一花了2毛", "老朱", null));
		set.add(new News(3, "双十一花了3毛", "老吴", null));
		set.add(new News(4, "双十一花了5毛", "老赵", null));
		News n4 = new News(15, "多过手了", "新华社发布", null);
		set.add(n4);
		Object[] n = set.toArray();
		for (int i = 0; i < n.length; i++) {
			News nt = (News) n[i];
			System.out.println(nt.getTitle());
		}
		System.out.println(">>>>>>>>>>增强for循环>>>>>>>>>");
		for (Object o : set) {
			News nt = (News) o;
			System.out.println(nt.getId() + "," + nt.getTitle());
		}
	}

}
